import { setRouteChange } from '@/logics/mitt/routeChange'
import router from '..'

const loadedPageMap = new Map<string, boolean>()

router.beforeEach(async (to: any) => {
  console.log('before')
  // The page has already been loaded, it will be faster to open it again, you don’t need to do loading and other processing
  to.meta.loaded = !!loadedPageMap.get(to.path)
  // Notify routing changes
  setRouteChange(to)

  return true
})

router.afterEach((to) => {
  console.log('afterEach')
  loadedPageMap.set(to.path, true)
})
